package com.zito.health.service.impl;

import com.zito.health.common.service.impl.BaseServiceImpl;
import com.zito.health.dto.ItemExpertDeclareDto;
import com.zito.health.entity.ItemExpertDeclare;
import com.zito.health.entity.ItemResearcher;
import com.zito.health.mapper.ItemExpertDeclareMapper;
import com.zito.health.service.ItemExpertDeclareService;
import com.zito.health.service.ItemResearcherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2019/11/11.
 */
@Service
public class ItemExpertDeclareServiceImpl extends BaseServiceImpl<ItemExpertDeclare> implements ItemExpertDeclareService {

    @Autowired
    private ItemExpertDeclareMapper itemExpertDeclareMapper;

    @Override
    public int queryMinExpert() {
        return itemExpertDeclareMapper.queryMinExpert();
    }

    public int save(Integer itemId, String ids){
        int res = 0;
        String[] idsStr = ids.split(",");
        for(String id : idsStr){
            ItemExpertDeclare itemExpertDeclare = new ItemExpertDeclare();
            itemExpertDeclare.setItemId(itemId);
            itemExpertDeclare.setExpertId(Integer.parseInt(id));
            itemExpertDeclare.setStates(1);
            for(int i = 0; i < 4; i++){
                res = res+itemExpertDeclareMapper.insertSelective(itemExpertDeclare);
            }
        }

        return res;
    }

    @Override
    public List<ItemExpertDeclareDto> queryList(ItemExpertDeclare item) {
        return itemExpertDeclareMapper.queryList(item);
    }

    @Override
    public Object listDetail(ItemExpertDeclare itemExpertDeclare) {
        return itemExpertDeclareMapper.select(itemExpertDeclare);
    }
}
